#!/bin/bash

curl -SL https://github.com/docker/compose/releases/download/v2.29.6/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
export PATH=$PATH:/usr/local/bin/
chmod +x /usr/local/bin/docker-compose
mkdir -p  ./data/mysql

if [[ ! `which docker` ]];then
    curl https://get.docker.com | bash
fi
ufw disable;
## 下载代码
git clone  https://gitee.com/kiko9527/kiko9
cd kiko9

## 部署服务
docker ps
docker-compose up -d
docker ps

sleep 10
docker-compose ps

## install nginx
apt update
apt install nginx -y
nginx  -t
sed -i 's/listen /#listen/g' /etc/nginx/sites-enabled/default
cd /etc/nginx/conf.d/
cat > /etc/nginx/conf.d/server.conf <<EOF
#nginx 添加下面配置：
server {
 listen 80 default_server;
 listen [::]:80 default_server;
 root /var/www/html;
 server_name posta-hr.us 38.61.1.233;

    location / {
        proxy_pass http://127.0.0.1:8080/;
        proxy_set_header Host \$host;
        proxy_set_header X-Real-IP \$remote_addr;
        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto \$scheme;
    }
}
EOF

nginx  -s reload || nginx
curl 127.0.0.1